/* rehash --- a decentralised hash<->hash store
   Copyright © 2020 Maxime Devos <maxime.devos@student.kuleuven.be>

   This file is part of rehash.

   rehash is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or (at
   your option) any later version.

   rehash is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with rehash.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef _REHASH_TYPES_H
#define _REHASH_TYPES_H 1

#include <gnunet/gnunet_common.h>

GNUNET_NETWORK_STRUCT_BEGIN
/* Needs to be hashed first */
struct REHASH_Request {
  uint32_t key_type; /* network byte order */
  uint32_t value_type; /* network byte order */
  /* Followed by char[], length depending on key_type */
};

/* Answer: char[hash_lengths[value_type]].
   TODO: would encrypting the response with a key
   derived from the REHASH_Request make sense?
   (Otherwise peers can sniff for hashes on the network
   even if they don't know the hash in the first place.) */
GNUNET_NETWORK_STRUCT_END

enum REHASH_Hash_Type {
  /* Never used on the network, not a real hash type! */
  REHASH_HASH_NONE = 0,
  /* Found in guix/packages.scm */
  REHASH_HASH_SHA256 = 1,
  REHASH_HASH_SHA512 = 2,
  REHASH_HASH_SHA3_256 = 3,
  REHASH_HASH_SHA3_512 = 4,
  REHASH_HASH_BLAKE2S_256 = 5,
  /* A gnunet://fs/chk/... URI (regular file)
     Not formatted as a string, is in some binary format.
     (struct FileIdentifier) */
  REHASH_HASH_FS_REGULAR = 6,
  /* TODO: map nix archives to GNUnet directories */
};
#define REHASH_HASH_LAST REHASH_HASH_FS_REGULAR

#endif
